#pragma once
#include <osg/Vec3d>

#include "CmdHandler3.h"

class TopoDS_Edge;
class Ent2DCurve;
class Ent2DCurve;
class Arc2D;
class UCS;
class SelectHandler3D;
class Fillet2DHandler : public CmdHandler3
{
	Q_OBJECT
public:
	Q_INVOKABLE Fillet2DHandler();
	~Fillet2DHandler();

	virtual void input(const QVariant& data, const QString& rawInput, CommandSource cs) override;

	bool getEdge(const gp_Pln& plane, TopoDS_Edge& e1, TopoDS_Edge& e2);
	int getSegmentNo(const std::shared_ptr<Ent2DCurve>& ent, const osg::Vec3d& choosePt);
	bool getChoosePt(osg::Vec3d& pt);
	void trimPolyline(const std::shared_ptr<Ent2DCurve>& originEnt, const int segNum, std::shared_ptr<Ent2DCurve>& trimEnt);
	bool trimLine(const std::shared_ptr<Arc2D>& fillet, const std::shared_ptr<Ent2DCurve>& originEnt, const int segNum, std::shared_ptr<Ent2DCurve>& trimEnt);
	bool trimArc(const std::shared_ptr<Arc2D>& fillet, const std::shared_ptr<Ent2DCurve>& originEnt, std::shared_ptr<Ent2DCurve>& trimEnt);
	bool trimSpline(const std::shared_ptr<Arc2D>& fillet, const std::shared_ptr<Ent2DCurve>& originEnt, const int segNum, std::shared_ptr<Ent2DCurve>& trimEnt);
	bool trimEnt(const std::shared_ptr<Arc2D>& fillet, const std::shared_ptr<Ent2DCurve>& originEnt, const int segNum, std::shared_ptr<Ent2DCurve>& trimEnt);
	static bool s_trim;//是否修剪
	static double s_radius;
	int m_segNum1;
	int m_segNum2;
	osg::Vec3d m_choosePt1;
	osg::Vec3d m_choosePt2;
	osg::Vec3d m_interPt;
	UCS* m_ucs;
	std::shared_ptr<Ent2DCurve> m_ent1;
	std::shared_ptr<Ent2DCurve> m_ent2;
};
